<?php
header("Content-Type: text/html; charset=iso-8859-1");
require 'include.php';
$action = (!empty($_REQUEST['action'])) ? $_REQUEST['action'] : "";
if($action == 'form_cookie'){
	echo "<h2>Antispam</h2>\n";
	echo "<form action = 'javascript:check_antispam(document.getElementById(\"antispam\").value)' name = 'form_antispam' method = 'post'>\n";
	echo "<p class = 'center'>Veuillez recopier le code ci-dessous</p>";
	echo "<p class = 'center'><img src = 'create_antispam.php' /></p>\n";
	echo "<p class = 'center'><input type = 'text' size = '5' maxlength= '5' name = 'antispam' id = 'antispam'/></p>\n";
	echo "<p class ='center'><button type = 'submit' value = '1'>valider</button></p>\n";
	echo "</form>\n";
}
elseif($action == 'check'){
	$value = (!empty($_REQUEST['value'])) ? $_REQUEST['value'] : "";
	$session = (!empty($_SESSION['antispam'])) ? $_SESSION['antispam'] : "";
	if(strtolower($value) == strtolower($session)){
		$param = time() +  60*60*24;
		$cookie = "EMAILOK";
		setcookie("VBCLL_EMAIL",$cookie,$param);
		echo 1;
	}
	else echo 0;
}
?>